<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

<p:dialog header="#{settlementIncomeListBean.header}" widgetVar="adding" modal="true" closable="true"
          resizable="true"
          style="position: absolute;">
    <p:outputPanel id="add-dialog">
        <div class="ui-g ui-fluid" style="width:1000px;">
            <div class="ui-g-2">
                <p:outputLabel value="产品名称"/>
            </div>
            <div class="ui-g-4">
                <p:selectOneMenu value="#{settlementIncomeListBean.settlementIncome.productId}"
                                 filter="true" updateLabel="true"
                                 filterMatchMode="contains">
                    <p:ajax event="change" listener="#{settlementIncomeListBean.onSelectProduct()}"
                            process="@this" update="add-dialog"/>
                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                  noSelectionOption="true"/>
                    <f:selectItems value="#{settlementIncomeListBean.productList}"
                                   var="dic"
                                   itemLabel="#{dic.productName}" itemValue="#{dic.id}"/>
                </p:selectOneMenu>
            </div>
            <div class="ui-g-2">
                <p:outputLabel value="主体名称"/>
            </div>
            <div class="ui-g-4">
                <p:selectOneMenu value="#{settlementIncomeListBean.settlementIncome.companyId}"
                                 filter="true" updateLabel="true"
                                 filterMatchMode="contains">
                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                  noSelectionOption="true"/>
                    <f:selectItems value="#{settlementIncomeListBean.companyList}"
                                   var="dic"
                                   itemLabel="#{dic.companyName}" itemValue="#{dic.id}"/>
                </p:selectOneMenu>
            </div>
            <div class="ui-g-2">
                <p:outputLabel value="合作模式"/>
            </div>
            <div class="ui-g-4">
                <p:selectOneMenu value="#{settlementIncomeListBean.settlementIncome.copMode}">
                    <p:ajax event="change" listener="#{settlementIncomeListBean.onChangeCopMode()}"
                            process="add-dialog"
                            update="add-dialog"/>
                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                  noSelectionOption="true"/>
                    <f:selectItems
                            value="#{settlementIncomeListBean.dictionaries[DictionaryCode.COOPERATION_MODE]}"
                            var="dic"
                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                </p:selectOneMenu>
            </div>

            <div class="ui-g-2">
                <p:outputLabel value="结算模式"/>
            </div>
            <div class="ui-g-4">
                <p:selectOneMenu value="#{settlementIncomeListBean.settlementIncome.settlementMode}">
                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                  noSelectionOption="true"/>
                    <f:selectItems
                            value="#{settlementIncomeListBean.dictionaries[DictionaryCode.SETTLEMENT_CYCLE]}"
                            var="dic"
                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                </p:selectOneMenu>
            </div>

            <div class="ui-g-2">
                <p:outputLabel value="收入类型"/>
            </div>
            <div class="ui-g-4">
                <p:selectOneMenu value="#{settlementIncomeListBean.settlementIncome.incomeType}">
                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                  noSelectionOption="true"/>
                    <f:selectItems
                            value="#{settlementIncomeListBean.dictionaries[DictionaryCode.SETTLEMENT_INCOME_TYPE]}"
                            var="dic"
                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                </p:selectOneMenu>
            </div>

            <p:outputPanel styleClass="ui-g-6 padding0" rendered="#{settlementIncomeListBean.settlementIncome.copMode==0
                                    || settlementIncomeListBean.settlementIncome.copMode==2
                                    || settlementIncomeListBean.settlementIncome.copMode==3}">
                <div class="ui-g-4">
                    <p:outputLabel value="结算价格（元）"/>
                </div>
                <div class="ui-g-8">
                    <p:inputNumber value="#{settlementIncomeListBean.settlementIncome.priceCpa}">
                        <p:ajax listener="#{settlementIncomeListBean.onChangeIncomeAmount()}" event="keyup"
                                update="incomeAmount"/>
                    </p:inputNumber>
                </div>
            </p:outputPanel>
            <p:outputPanel styleClass="ui-g-6 padding0" rendered="#{settlementIncomeListBean.settlementIncome.copMode==1
                                    || settlementIncomeListBean.settlementIncome.copMode==3}">
                <div class="ui-g-4">
                    <p:outputLabel value="结算价格（%）"/>
                </div>
                <div class="ui-g-8">
                    <p:inputText value="#{settlementIncomeListBean.settlementIncome.priceCps}">
                        <p:ajax listener="#{settlementIncomeListBean.onChangeIncomeAmount()}" event="keyup"
                                update="incomeAmount"/>
                        <f:convertNumber pattern="#,##0.00"/>
                    </p:inputText>
                </div>
            </p:outputPanel>

            <div class="ui-g-2">
                <p:outputLabel value="推广方式"/>
            </div>
            <div class="ui-g-4">
                <p:selectOneMenu value="#{settlementIncomeListBean.settlementIncome.spreadMode}">
                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                  noSelectionOption="true"/>
                    <f:selectItems
                            value="#{settlementIncomeListBean.dictionaries[DictionaryCode.SETTLEMENT_SPREAD_MODE]}"
                            var="dic"
                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                </p:selectOneMenu>
            </div>
            <div class="ui-g-2">
                <p:outputLabel value="推广渠道"/>
            </div>
            <div class="ui-g-4">
                <p:selectOneMenu value="#{settlementIncomeListBean.settlementIncome.spreadChannel}">
                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                  noSelectionOption="true"/>
                    <f:selectItems
                            value="#{settlementIncomeListBean.dictionaries[DictionaryCode.SETTLEMENT_SPREAD_CHANNEL]}"
                            var="dic"
                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                </p:selectOneMenu>
            </div>


            <div class="ui-g-2">
                <p:outputLabel value="开始日期"/>
            </div>
            <div class="ui-g-4">
                <p:calendar
                        value="#{settlementIncomeListBean.settlementIncome.startTime}"
                        locale="#{constants:get('LOCALE')}"
                        timeZone="#{constants:get('TIME_ZONE')}"
                        pattern="#{constants:get('DATE_FORMAT')}">
                    <p:ajax event="dateSelect"
                            listener="#{settlementIncomeListBean.onChangeParticipateUv()}" process="@this"
                    />
                </p:calendar>
            </div>
            <div class="ui-g-2">
                <p:outputLabel value="结束日期"/>
            </div>
            <div class="ui-g-4">
                <p:calendar
                        value="#{settlementIncomeListBean.settlementIncome.endTime}"
                        locale="#{constants:get('LOCALE')}"
                        timeZone="#{constants:get('TIME_ZONE')}"
                        pattern="#{constants:get('DATE_FORMAT')}">
                    <p:ajax event="dateSelect"
                            listener="#{settlementIncomeListBean.onChangeParticipateUv()}" process="@this"/>
                </p:calendar>
            </div>


            <p:outputPanel styleClass="ui-g-6 padding0" rendered="#{settlementIncomeListBean.settlementIncome.copMode==0
                                    || settlementIncomeListBean.settlementIncome.copMode==3}">
                <div class="ui-g-4">
                    <p:outputLabel value="注册数"/>
                </div>
                <div class="ui-g-8">
                    <p:inputText value="#{settlementIncomeListBean.settlementIncome.registerCount}">
                        <p:ajax listener="#{settlementIncomeListBean.onChangeIncomeAmount()}" event="keyup"
                                update="incomeAmount"/>
                    </p:inputText>
                </div>
            </p:outputPanel>
            <p:outputPanel styleClass="ui-g-6 padding0" rendered="#{settlementIncomeListBean.settlementIncome.copMode==1
                                    || settlementIncomeListBean.settlementIncome.copMode==3}">
                <div class="ui-g-4">
                    <p:outputLabel value="放款金额"/>
                </div>
                <div class="ui-g-8">
                    <p:inputNumber value="#{settlementIncomeListBean.settlementIncome.lendAmount}">
                        <p:ajax listener="#{settlementIncomeListBean.onChangeIncomeAmount()}" event="keyup"
                                update="incomeAmount"/>
                    </p:inputNumber>
                </div>
            </p:outputPanel>

            <p:outputPanel styleClass="ui-g-6 padding0"
                           rendered="#{settlementIncomeListBean.settlementIncome.copMode==2}">
                <div class="ui-g-4">
                    <p:outputLabel value="点击数"/>
                </div>
                <div class="ui-g-8">
                    <p:inputText value="#{settlementIncomeListBean.settlementIncome.clickCount}">
                        <p:ajax listener="#{settlementIncomeListBean.onChangeIncomeAmount()}" event="keyup"
                                update="incomeAmount"/>
                    </p:inputText>
                </div>
            </p:outputPanel>

            <div class="ui-g-2">
                <p:outputLabel value="结算金额"/>
            </div>
            <div class="ui-g-4">
                <p:inputNumber id="incomeAmount"
                               value="#{settlementIncomeListBean.settlementIncome.incomeAmount}">
                </p:inputNumber>
            </div>

            <div class="ui-g-12 padding0">
                <div class="ui-g-2">
                    <p:outputLabel for="selectActivity" value="关联活动"/>
                </div>
                <div class="ui-g-10">
                    <p:selectCheckboxMenu id="selectActivity"
                                          value="#{settlementIncomeListBean.activityIdList}"
                                          updateLabel="true" multiple="true" filter="true"
                                          filterMatchMode="contains">
                        <f:selectItems value="#{settlementIncomeListBean.activityList}" var="activity"
                                       itemValue="#{activity.id}"
                                       itemLabel="#{activity.name}(#{activity.id})"/>
                    </p:selectCheckboxMenu>
                </div>
            </div>
            <div class="ui-g-12" style="padding: 0">
                <div class="ui-g-2">
                    <p:outputLabel for="selectActivity" value="备注"/>
                </div>
                <div class="ui-g-10">
                    <p:inputText value="#{settlementIncomeListBean.settlementIncome.remark}"/>
                </div>
            </div>

            <div class="ui-g-12">
                <p:commandButton value="保存" style="float: right"
                                 actionListener="#{settlementIncomeListBean.onSave()}"
                                 process="@this add-dialog"
                                 rendered="#{settlementIncomeListBean.settlementIncome.billId==null and settlementIncomeListBean.hasSeeRight==true}"/>
            </div>
        </div>
    </p:outputPanel>
</p:dialog>

</html>
